// 标签系统相关的getters
export default {
  // 获取所有标签
  tags: state => state.tags,
  
  // 获取当前包的标签
  packageTags: state => state.packageTags,
  
  // 获取加载状态
  loading: state => state.loading,
  
  // 获取保存状态
  saving: state => state.saving,
  
  // 获取删除状态
  deleting: state => state.deleting,
  
  // 获取错误信息
  error: state => state.error,
  
  // 获取当前包名称
  currentPackageName: state => state.currentPackageName,
  
  // 获取标签数量
  tagCount: state => state.tags.length,
  
  // 获取当前包的标签数量
  packageTagCount: state => state.packageTags.length,
  
  // 检查是否有标签
  hasTags: state => state.tags.length > 0,
  
  // 检查当前包是否有标签
  hasPackageTags: state => state.packageTags.length > 0,
  
  // 根据ID获取标签
  getTagById: state => id => state.tags.find(tag => tag.id === id),
  
  // 根据名称获取标签
  getTagByName: state => name => state.tags.find(tag => tag.name === name),
  
  // 获取当前包未分配的标签
  availableTags: state => {
    const packageTagIds = state.packageTags.map(tag => tag.id)
    return state.tags.filter(tag => !packageTagIds.includes(tag.id))
  },
  
  // 检查标签是否已分配给当前包
  isTagAssigned: state => tagId => {
    return state.packageTags.some(tag => tag.id === tagId)
  },
  
  // 获取标签的使用次数（这里是模拟数据，实际项目中应该从API获取）
  tagUsageCount: state => tagId => {
    // 模拟数据，实际项目中应该从API获取
    return Math.floor(Math.random() * 10) + 1
  },
  
  // 获取标签列表的选项格式（用于表单选择）
  tagOptions: state => {
    return state.tags.map(tag => ({
      value: tag.id,
      label: tag.name
    }))
  }
}